package org.yankun.exam4j.web.controller.exam;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.yankun.exam4j.core.exam.service.ExamService;
import org.yankun.exam4j.core.paper.service.PaperService;
import org.yankun.exam4j.entity.Exam;
import org.yankun.exam4j.entity.Paper;


@Controller("ExamController")
@RequestMapping("/exam")
public class ExamController {
	
	@Resource
	private ExamService examService;
	
	@Resource
	private PaperService paperService;
	
	@RequestMapping(value="{examId}/detail.do")
	public ModelAndView toIndex(HttpServletResponse response,HttpServletRequest request,@PathVariable("examId") Integer examId){
		Map<String, Object> map=new HashMap<String, Object>();
		
		Exam exam = examService.getExamById(examId);
		List<Paper> paperList = paperService.getPapersByExamId(examId);
		
		map.put("exam", exam);
		map.put("paperList", paperList);
		return new ModelAndView("/exam/detail",map);
	}
	
}